package com.ruoyi.web.controller.xcx;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.AOperationRecords;
import com.ruoyi.system.domain.AUser;
import com.ruoyi.system.domain.vo.WxSignVO;
import com.ruoyi.system.service.IAUserService;
import com.ruoyi.system.util.LoginUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 小程序用户Controller
 *
 * @author ruoyi
 * @date 2024-05-16
 */
@RestController
@RequestMapping("/xcx/aUser")
public class XcxAUser extends BaseController {

    @Autowired
    private IAUserService aUserService;

    @GetMapping ("/xcxUpdate")
    public AjaxResult xcxUpdate(AOperationRecords aOperationRecords)
    {
        return toAjax(aUserService.updateXcxAUser(aOperationRecords));
    }

    @GetMapping ("/getXcxUser")
    public AjaxResult getXcxUser()
    {
        return success(LoginUtils.getUser());
    }

    @PostMapping ("/updateXcxUser")
    public AjaxResult updateXcxUser(@RequestBody AUser aUser)
    {
        return success(aUserService.updateXcxUser(aUser));
    }


    @GetMapping ("/getGzhUser")
    public AjaxResult getGzhUser()
    {
        return success(aUserService.getGzhUser());
    }


    /**
     * 根据appid 获取token
     * @return
     */
    @GetMapping("/getWxToken")
    public AjaxResult getWxToken()
    {
        return success(aUserService.getWxToken());
    }

    /**
     * 根据appid 获取token
     * 根据token 获取api_ticket
     * @return
     */

    @GetMapping("/getJsapiTicket")
    public AjaxResult getJsapiTicket()
    {
        return success(aUserService.getJsapiTicket());
    }

    /**
     * 返回签名
     * @return
     */
    @GetMapping("/getUserSign")
    public AjaxResult getUserSign(WxSignVO vo)
    {
        return success(aUserService.getUserSign(vo));
    }
}
